package validator

import (
	"gopkg.in/go-playground/validator.v9"
	"regexp"
)

const (
	phonePattern = `^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*$`
)

var (
	phoneRegex = regexp.MustCompile(phonePattern)
)

func PhoneValidateFunc(fl validator.FieldLevel) bool {
	p := fl.Field().String()
	return phoneRegex.MatchString(p)
}
